package guo.enhanceAop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Order(1)
public class AroundAop {

    @Around("guo.enhanceAop.LogAop.pc()")
    public Object AroundAopOne(ProceedingJoinPoint joinPoint){
        Object obj = null;

        Object[] args = joinPoint.getArgs();
        try {
            System.out.println("方法执行前**********");
            obj = joinPoint.proceed(args);
            System.out.println("方法正常执行后***********");
        } catch (Throwable e) {
            System.out.println("抛出异常");
            throw new RuntimeException(e);
        } finally {
            System.out.println("最终一定会执行**********");
        }
        return obj;
    }
}
